﻿Imports System.Windows.Forms
Imports Microsoft.Win32

Public Class Options
    Dim resetTZ As Boolean = False
    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub bPurge_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bPurge.Click


        If MessageBox.Show("Selecting yes will remove all the " & vbCrLf & "time zone to location associations in your cache.", "Purge", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
            resetTZ = True
        
            Dim rootValue As String = "\Software\Outlook2007DIT\Locations"
            Try
                My.Computer.Registry.CurrentUser.DeleteSubKeyTree(rootValue)
            Catch
            End Try
        End If

    End Sub
    Overloads Function ShowDialog() As Boolean
        ' passing in owner so that we don't get into an infinate recursive calling loop

        Me.ShowDialog(Me.Owner)
        ShowDialog = resetTZ

    End Function


    Private Sub bhelp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bhelp.Click

        Dim filename As String

        filename = Replace(Reflection.Assembly.GetExecutingAssembly.CodeBase, "/Outlook2007DIT.DLL", "\outlook_2007_dit.chm")
        filename = Replace(filename, "file:///", "")
        filename = Replace(filename, "/", "\")


        If True = Microsoft.VisualBasic.FileIO.FileSystem.FileExists(filename) Then

            'Dim fs As System.IO.Stream
            'fs = Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("outlook_2007_dit")
            'tb1.Text = tb1.Text & vbCrLf & "reflection.Assembly.GetExecutingAssembly.Location:" & Reflection.Assembly.GetExecutingAssembly.Location & vbCrLf
            'tb1.Text = tb1.Text & vbCrLf & "reflection.Assembly.GetExecutingAssembly.CodeBase " & Reflection.Assembly.GetExecutingAssembly.CodeBase & vbCrLf
            'tb1.Text = tb1.Text & vbCrLf & "reflection.Assembly.GetExecutingAssembly.ManifestModule.FullyQualifiedName " & Reflection.Assembly.GetExecutingAssembly.ManifestModule.FullyQualifiedName
            Help.ShowHelp(Me, filename)
        Else
            MsgBox("Help file could not be found." & vbCrLf & filename)
        End If

    End Sub

    Private Sub bAbout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bAbout.Click
        Dim f As New AboutBoxOutlook2007DIT
        f.ShowDialog()

    End Sub
End Class
